package com.hopu.controller;

import com.hopu.entity.Result;
import com.hopu.entity.User;
import com.hopu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 新增(注册)用户
     *
     * @param user
     * @return
     */
    @PostMapping("/register")
    public Result save(@RequestBody User user) {
        userService.save(user);
        return Result.success();
    }
//    获取用户资料
    @PutMapping("/{UserId}")
    public ResponseEntity<User>updateUser(@PathVariable String UserId,
                                          @RequestBody User user) {
        user.setUserId(user.getUserId());
        User updateUser = userService.updateUserInfo(user);
        return ResponseEntity.ok(updateUser);
    }



}
